﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using Sahit.iSoilHotel.Domain.MainBoundedContext.Tavern.Aggregates.RecordAgg;

namespace Sahit.iSoilHotel.Infrastructure.DataAccess.MainBoundedContext.Tavern.Mapping.Records
{
    public class RecordMap:
        EntityTypeConfiguration<Record>
    {
        public RecordMap()
        {
            this.ToTable("Record");

            this.HasKey(r => r.ID);
            this.Property(r => r.StartDate);
            this.Property(r => r.EndDate);

            this.Ignore(r => r.Status);
            this.Property(r => r.StatusID);

            this.HasRequired(r => r.Price).WithMany().HasForeignKey(r=>r.PriceID).WillCascadeOnDelete(true);
            this.HasRequired(r => r.PriceCode).WithMany().HasForeignKey(r => r.PriceCodeID).WillCascadeOnDelete(false);
            this.HasRequired(r => r.Room).WithMany().HasForeignKey(r => r.RoomID).WillCascadeOnDelete(false);
            this.HasMany(r => r.Customers).WithMany().Map(m => m.ToTable("Record_Customer_Mapping"));
        }
    }
}
